///////////////////////////////////////////////////////////////////////////////////////////////////
// Illusion Ray Development Kit (IDK)           Copyright (c) 2010 ( dimitriy.martynenko@gmail.com )
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-05-22
// Updated : ...
// Licence : NEW BSD
// Info	   : IDK Engine
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
/*-------------------------------------------------------------------------
| BasicCamera:
| ------------
| BasicCamera
---------------------------------------------------------------------------*/
class ThirdPersonCamera : public TBasicCamera
{
	typedef TBasicCamera Base;
public:
    ThirdPersonCamera();
    virtual ~ThirdPersonCamera();

    virtual void LookAt(const Math::Vector3& target);
    void LookAt(const Math::Vector3& eye, const Math::Vector3& target, const Math::Vector3& up);
	virtual void Rotate(float x, float y);
	virtual void Update(float elapsedTimeSec);
	virtual const Math::Vector3& GetPosition(void) const
	{
		return m_eye;
	}
	virtual void CalculateMatrix(IDK::ICamera::MatrixMode::Enum mode, Math::Matrix44& dest);
private:
    void UpdateOrientation(float elapsedTimeSec);
    void UpdateViewMatrix(float elapsedTimeSec);

    static const float DEFAULT_SPRING_CONSTANT;
    static const float DEFAULT_DAMPING_CONSTANT;
    static const float DEFAULT_FOVX;
    static const float DEFAULT_ZFAR;
    static const float DEFAULT_ZNEAR;
    static const Math::Vector3 WORLD_XAXIS;
    static const Math::Vector3 WORLD_YAXIS;
    static const Math::Vector3 WORLD_ZAXIS;

    float m_springConstant;
    float m_dampingConstant;
    float m_offsetDistance;
    float m_headingDegrees;
    float m_pitchDegrees;
    Math::Vector3 m_eye;
    Math::Vector3 m_target;
    Math::Vector3 m_targetYAxis;
    Math::Vector3 m_xAxis;
    Math::Vector3 m_yAxis;
    Math::Vector3 m_zAxis;
    Math::Vector3 m_viewDir;
    Math::Vector3 m_velocity;
    Math::Quaternion m_orientation;
};